//
//  UserFeedbackController.m
//  OnionHome
//
//  Created by fengjie on 2019/9/14.
//  Copyright © 2019 FengJie. All rights reserved.
//

#import "UserFeedbackController.h"

@interface UserFeedbackController ()
/**信息分类*/
@property (nonatomic,strong)UIButton*oneButton;
/**功能异常*/
@property (nonatomic,strong)UIButton*twoButton;
/**其他*/
@property (nonatomic,strong)UIButton*thereButton;

/**<#属性#>*/
@property (nonatomic,strong)PubulicTextView*textView;
/**<#属性#>*/
@property (nonatomic,strong)UITextField*textFile;
@end

@implementation UserFeedbackController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"我要反馈";
    self.view.backgroundColor = UIColorFromRGB(0xF5F7F5);
    [self createUI];
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self setNavBarBackgroundAndNotClearColor];
}
-(void)createUI{
    UIView * oneView = [self oneView];
    UIView * twoView = [self twoView];
    UIView * thereView = [self thereView];
    
    UIButton * commitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [commitBtn setTitle:@"提交" forState:UIControlStateNormal];
    [commitBtn setBackgroundImage:[UIImage createImageWithColor:UIColorFromRGB(0x009966)] forState:UIControlStateNormal];
    ViewRadius(commitBtn, 5);
    commitBtn.titleLabel.font = PingFangSC_Medium(18);
    
    [self.view addSubview:oneView];
    [self.view addSubview:twoView];
    [self.view addSubview:thereView];
    [self.view addSubview:commitBtn];
    
    [oneView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(16);
        make.height.mas_equalTo(40);
    }];
    [twoView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(oneView.mas_bottom).offset(8);
        make.height.mas_equalTo(174);
    }];
    [thereView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(twoView.mas_bottom).offset(16);
        make.height.mas_equalTo(40);
    }];
    [commitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(-30);
        make.left.mas_equalTo(40);
        make.right.mas_equalTo(-40);
        make.height.mas_equalTo(50);
    }];
}
-(UIView *)oneView{
    UIView * view = [[UIView alloc] initWithFrame:CGRectZero];
    view.backgroundColor = UIColor.whiteColor;
    UILabel * label = UILabel.new;
    label.textColor = UIColorFromRGB(0x273323);
    label.font = PingFangSC_Regular(16);
    label.text = @"反馈建议类型";
    
    [view addSubview:label];
    
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(16);
    }];
    
    return view;
}
-(UIView *)twoView{
    UIView * view = [[UIView alloc] initWithFrame:CGRectZero];
    view.backgroundColor = UIColor.whiteColor;
    
    UIView * line = UIView.new;
    line.backgroundColor = SeparatorColor;
    
    [view addSubview:self.oneButton];
    [view addSubview:self.twoButton];
    [view addSubview:self.thereButton];
    [view addSubview:line];
    [view addSubview:self.textView];
    
    [self.oneButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(12);
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(26);
    }];
    [self.twoButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.oneButton.mas_right).offset(8);
        make.top.mas_equalTo(12);
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(26);
    }];
    [self.thereButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.twoButton.mas_right).offset(8);
        make.top.mas_equalTo(12);
        make.width.mas_equalTo(47);
        make.height.mas_equalTo(26);
    }];
    
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.right.mas_equalTo(-16);
        make.height.mas_equalTo(0.5);
        make.top.mas_equalTo(self.oneButton.mas_bottom).offset(12);
    }];
    
    [self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.right.mas_equalTo(-60);
        make.top.mas_equalTo(line.mas_bottom).offset(16);
        make.bottom.mas_equalTo(-10);
    }];

    return view;
}
-(UIView *)thereView{
    UIView * view = [[UIView alloc] initWithFrame:CGRectZero];
    view.backgroundColor = UIColor.whiteColor;
    UILabel * label = UILabel.new;
    label.textColor = UIColorFromRGB(0x273323);
    label.font = PingFangSC_Regular(16);
    label.text = @"联系手机";
    
    [view addSubview:label];
    [view addSubview:self.textFile];
    
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(16);
    }];
    [self.textFile mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(label.mas_right).offset(10);
        make.width.mas_equalTo(200);
        make.top.bottom.mas_equalTo(0);
    }];
    
    return view;
}
-(UIButton*)oneButton{
    if(!_oneButton){
        _oneButton=[UIButton buttonWithType:UIButtonTypeCustom];
        [_oneButton setTitle:@"信息分类" forState:UIControlStateNormal];
        _oneButton.titleLabel.font = PingFangSC_Regular(14);
        [_oneButton setBackgroundImage:[UIImage createImageWithColor:UIColorFromRGB(0xF5F7F5)] forState:UIControlStateNormal];
        [_oneButton setBackgroundImage:[UIImage createImageWithColor:UIColorFromRGB(0x009966)] forState:UIControlStateSelected];
        [_oneButton setTitleColor:UIColorFromRGB(0x454F44) forState:UIControlStateNormal];
        [_oneButton setTitleColor:UIColorFromRGB(0xFFFFFF) forState:UIControlStateSelected];
        
        _oneButton.selected = YES;
        
        ViewRadius(_oneButton, 5);

        kWeakSelf(weakSelf);
        [_oneButton addActionHandler:^{
            weakSelf.oneButton.selected = YES;
            weakSelf.twoButton.selected = NO;
            weakSelf.thereButton.selected = NO;
        }];

    }
    return _oneButton;
}
-(UIButton*)twoButton{
    if(!_twoButton){
        _twoButton=[UIButton buttonWithType:UIButtonTypeCustom];
        [_twoButton setTitle:@"功能异常" forState:UIControlStateNormal];
        [_twoButton setBackgroundImage:[UIImage createImageWithColor:UIColorFromRGB(0xF5F7F5)] forState:UIControlStateNormal];
        [_twoButton setBackgroundImage:[UIImage createImageWithColor:UIColorFromRGB(0x009966)] forState:UIControlStateSelected];
        [_twoButton setTitleColor:UIColorFromRGB(0x454F44) forState:UIControlStateNormal];
        [_twoButton setTitleColor:UIColorFromRGB(0xFFFFFF) forState:UIControlStateSelected];
        _twoButton.titleLabel.font = PingFangSC_Regular(14);

        _twoButton.selected = NO;
        
        ViewRadius(_twoButton, 5);
        
        kWeakSelf(weakSelf);
        [_twoButton addActionHandler:^{
            weakSelf.oneButton.selected = NO;
            weakSelf.twoButton.selected = YES;
            weakSelf.thereButton.selected = NO;
        }];

    }
    return _twoButton;
}
-(UIButton*)thereButton{
    if(!_thereButton){
        _thereButton=[UIButton buttonWithType:UIButtonTypeCustom];
        [_thereButton setTitle:@"其他" forState:UIControlStateNormal];
        [_thereButton setBackgroundImage:[UIImage createImageWithColor:UIColorFromRGB(0xF5F7F5)] forState:UIControlStateNormal];
        [_thereButton setBackgroundImage:[UIImage createImageWithColor:UIColorFromRGB(0x009966)] forState:UIControlStateSelected];
        [_thereButton setTitleColor:UIColorFromRGB(0x454F44) forState:UIControlStateNormal];
        [_thereButton setTitleColor:UIColorFromRGB(0xFFFFFF) forState:UIControlStateSelected];
        _thereButton.titleLabel.font = PingFangSC_Regular(14);

        _thereButton.selected = NO;
        
        ViewRadius(_thereButton, 5);
        
        kWeakSelf(weakSelf);
        [_thereButton addActionHandler:^{
            weakSelf.oneButton.selected = NO;
            weakSelf.twoButton.selected = NO;
            weakSelf.thereButton.selected = YES;
        }];

    }
    return _thereButton;
}
-(PubulicTextView*)textView{
    if(!_textView){
        _textView=[[PubulicTextView alloc] initWithFrame:CGRectZero];
        _textView.placeholderText.attributedText = [TitleTool getAttributeStringLineSpacing:3 title:@"描述您遇到的相关问题（必填15-500字),如有问题需要咨询或解决，请联系只能客服" titleColor:UIColorFromRGB(0x959E97) titleFont:PingFangSC_Regular(14)];
    }
    return _textView;
}
-(UITextField*)textFile{
    if(!_textFile){
        _textFile=[UITextField new];
        _textFile.placeholder = @"输入手机号";
    }
    return _textFile;
}
@end
